# Contributor: graysky <graysky AT archlinux dot us>

# set this to a null to omit the docs and licenses
_installdocs=yes

pkgname=('linpack')
pkgver=2021.1.1.001
_pkgvershort=2021.1.1
_number=4942
pkgrel=2
arch=('i386' 'x86_64')
pkgdesc='Benchmark based on linear algebra excellent app for stress testing.'
license=('custom')
url="http://software.intel.com/en-us/articles/intel-math-kernel-library-linpack-download"
source=("https://software.intel.com/content/dam/develop/external/us/en/documents/l_mklb_p_2021.1.1.001.tgz"
'linpack.conf' 'runme.template')
install=readme.install
backup=(etc/linpack.conf)
sha256sums=('56e9970b8f950c6aee53060818a8af47afc26f8f04991f14fccc46dbae4776a1'
            'd7e31c8c7e2648c8fa3c4838d98dfc39b8fadf0f74bdaa4ca52cd38277ec8254'
            '8c880adeee3de6c0e6005e210cea0e01b471219c590e25e824298a25ab0eef31')

build() {
	[[ -z "$CARCH" ]] && echo "Cannot determine architecture of this system!" && exit 1
	[[ "$CARCH" = "x86_64" ]] && bit=64 || bit=32
	export bit
	
	# setup based on detected arch
	sed -e "s/@TARGET_BIT@/$bit/g" <runme.template >linpack_runme_xeon$bit
}

package_linpack() {
	_path="$srcdir/l_mklb_p_2021.1.1.001/benchmarks_2021.1.1/linux/mkl/benchmarks/linpack"

	#	config files
	install -Dm755 "$_path/runme_xeon$bit" "$pkgdir/lkp/benchmarks/linpack/runme_xeon$bit"
	
	# bins
	install -Dm755 "$_path/xlinpack_xeon$bit" "$pkgdir/lkp/benchmarks/linpack/xlinpack_xeon$bit"
	install -Dm644 "$_path/xhelp.lpk" "$pkgdir/usr/share/doc/${pkgname}/xhelp.lpk"
}
